<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/manage/system/pageBase.jsp" %>
<%@ page info="案例列表" %>
<%
    Map<String,String> statuss = new LinkedHashMap<String,String>();
    statuss.put("y","显示");
    statuss.put("n","不显示");
%>
<form action="<%=path %>/manage/case" name="form" id="form" method="post">
    <div style="height:auto!important;height:550px;min-height:550px;">
        <h3 style="border-bottom: 1px solid #D7D7D7;color: #666666;font-size: 28px;padding-bottom: 20px;margin-bottom: 30px;">
            <%=getServletInfo()%>
            <a href="<%=path %>/manage/case/selectList" class="btn btn-primary"
               style="padding: 2px 15px;float:right;"><i class="icon-double-angle-left"></i>返回列表</a>
        </h3>
        <table width="100%" border="0" cellspacing="0" cellpadding="10" class="tableBasic">

            <tr style="display: none;">
                <td>id</td>
                <td><input type="hidden" value="${e.id}" name="id" label="id"/></td>
            </tr>
            
            
             <tr>
                <th style="text-align: right;">选择分类</th>
                <td style="text-align: left;">
                    <select id="typeId" name="typeId">
                        <c:forEach var="item" items="<%=SystemManage.getInstance().getCaseType()%>">
                            <option value="${item.id}" <c:if test="${e.typeId eq item.id}">selected="selected" </c:if>>${item.name}</option>
                        </c:forEach>
                    </select>
                </td>
            </tr>
            
            
            
            <tr>
                <th style="text-align: right;" width="200">案例名称</th>
                <td style="text-align: left;">
                    <input type="text" size="40" value="${e.caseName}" name="caseName"
                                                     data-rule="文章标题:required;title;length[1~45];"
                                                     id="caseName"/>
                </td>
            </tr>
            
             <tr>
                <th style="text-align: right;">案例介绍</th>
                <td style="text-align: left;">
                    <textarea id="introduce" name="introduce" class="textArea" cols="120"
                              rows="4">${e.introduce}</textarea>
                </td>
            </tr>

            <tr>
                <th style="text-align: right;">案例图片</th>
                <td style="text-align: left;">
                    <input type="text"  size="40" id="image" name="image" value="${e.image}"/>
                    <input type="button" name="imageFile" value="浏览图片" class="btn btn-primary" style="padding: 0px 12px;margin-top: -5px;"/>
                    <c:choose>
                        <c:when test="${!empty e.image}">
                            <a target="_blank" href="<%=SystemManage.getInstance().getSystemSetting().getImageRootPath()%>/${e.image}">
                                <img style="max-width: 50px;max-height: 50px;" alt="" src="<%=SystemManage.getInstance().getSystemSetting().getImageRootPath()%>/${e.image}">
                            </a>
                        </c:when>
                    </c:choose>
                </td>
            </tr>
            <tr>
                <th style="text-align: right;">是否推荐</th>
                <td style="text-align: left;">  
                	<input type="radio" name="recomment"  value="1" <c:if test="${e.recomment eq '1'}"> checked="true" </c:if> /> 是
                	<input type="radio" name="recomment"  value="0" <c:if test="${e.recomment eq '0'}"> checked="true" </c:if> /> 否
               	</td>
            </tr>
           
            <tr>
                <th style="text-align: right;">关联链接</th>
                <td style="text-align: left;"><input type="text" size="80" value="${e.linkUrl}" name="linkUrl"
                                                     id="linkUrl"/></td>
            </tr>
            
            </tr>
           
 
            <tr>
                <td colspan="2" style="text-align: center;">
                    <c:choose>
                        <c:when test="${e.id!=0}">
                            <button method="update" onclick="commit(this)" class="btn btn-info"
                                    style="padding:2px 15px;">
                                保存
                            </button>
                        </c:when>
                        <c:otherwise>
                            <button method="insert" onclick="commit(this)" class="btn btn-info"
                                    style="padding:2px 15px;">
                                新增
                            </button>
                        </c:otherwise>
                    </c:choose>
                </td>
            </tr>
        </table>
    </div>
</form>

<script type="text/javascript">

var content;
KindEditor.ready(function (K) {
    content = K.create('textarea[name="content"]', {
        filterMode: false,
        allowFileManager: true,
        uploadJson: '<%=path%>/resource/kindeditor/jsp/upload_json.jsp',
        fileManagerJson: '<%=path%>/resource/kindeditor/jsp/file_manager_json.jsp'

    });
    var editor = K.editor({
        allowFileManager : true,
        uploadJson: '<%=path%>/resource/kindeditor/jsp/upload_json.jsp',
        fileManagerJson : '<%=path%>/resource/kindeditor/jsp/file_manager_json.jsp'
    });

    K('input[name=getHtml]').click(function (e) {
        alert(editor.html());
    });
    K('input[name=isEmpty]').click(function (e) {
        alert(editor.isEmpty());
    });
    K('input[name=getText]').click(function (e) {
        alert(editor.text());
    });
    K('input[name=selectedHtml]').click(function (e) {
        alert(editor.selectedHtml());
    });
    K('input[name=setHtml]').click(function (e) {
        editor.html('<h3>Hello KindEditor</h3>');
    });
    K('input[name=setText]').click(function (e) {
        editor.text('<h3>Hello KindEditor</h3>');
    });
    K('input[name=insertHtml]').click(function (e) {
        editor.insertHtml('<strong>插入HTML</strong>');
    });
    K('input[name=appendHtml]').click(function (e) {
        editor.appendHtml('<strong>添加HTML</strong>');
    });
    K('input[name=imageFile]').click(function() {

        editor.loadPlugin('image', function() {
            editor.plugin.imageDialog({
                imageUrl : K('#image').val(),
                clickFn : function(url) {
                    url = url.substring(20)
                    K('#image').val(url);
                    editor.hideDialog();
                }
            });
        });

    });


    K('input[name=clear]').click(function (e) {
        editor.html('');
    });

});


    function commit(obj) {
        var _form = $("form");
        _form.attr("action", $(obj).attr("method"));
        _form.submit();
    }

</script>


<%@ include file="/manage/system/baseFoot.jsp" %>
